# -*- coding: utf-8 -*-
import autocomplete_light
from mdcsapp.models import PlayerUserProfile

class PlayerUserProfileAutocomplete(autocomplete_light.AutocompleteModelBase):
    choices = PlayerUserProfile.objects.all()
    search_fields = ('user__username', 'user__first_name', 'user__last_name')
    autocomplete_js_attributes={'minimum_characters': 1, 'placeholder': u'Unesite ime igrača...'}
    model = PlayerUserProfile

    def choice_value(self, choice):
        return choice.id
    
    def choices_for_values(self):
        values = []
        for i in self.values:
            values.append(int(i))
        return self.choices.filter(id__in=values)

autocomplete_light.register(PlayerUserProfileAutocomplete)